# -*- coding:utf-8 -*-
#包名 是指项目的包名
package = 'com.bawei.mydialog';
#activity
activity = '.MainActivity';
component = package+"/"+activity;
#封装休眠方法
def Sleep():
   MonkeyRunner.sleep(5);
##导包
from com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImage
from com.android.monkeyrunner.easy import EasyMonkeyDevice,By
from com.android.chimpchat.hierarchyviewer import HierarchyViewer;
from com.android.hierarchyviewerlib.device import ViewNode
#链接手机
device = MonkeyRunner.waitForConnection();
#开启activity
device.startActivity(component = component);
#获取hierarchyviewer,得到这个方法
hierarchyviewer = device.getHierarchyViewer();
#获取控件
ll_dialog=hierarchyviewer.findViewById('id/ll_dialog');
btn_cammer=hierarchyviewer.findViewById('id/btn_cammer');
#获取控件的高度和宽度
btn_width = int (btn_cammer.width);
btn_height = int (btn_cammer.height);
#获取屏幕的宽度和高度
a=device.getProperty('display.height');
b=device.getProperty('display.width');
height =int (a);
width =int (b);
#开始进行拍照
device.touch(width/2, height - btn_height*2-btn_height/2,'DOWN_AND_UP');
Sleep();
# 相册
device.touch(width/2, height - btn_height -btn_height/2,'DOWN_AND_UP');
Sleep();
# 取消
device.touch(width/2,height - btn_height/2,'DOWN_AND_UP');